<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户栏</title>
    <link rel="stylesheet" href="css/globe.css"/>
    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript">
        function exit() {
            if (confirm("您确定要退出登录吗？")) {
                $.ajax({
                    url: "${pageContext.request.contextPath}/user/exit",
                    type: "post",
                    success: function () {
                        sessionStorage.removeItem("admin");
                        window.location.href = "${pageContext.request.contextPath}/index.jsp";
                    },

                });
            }
        }
    </script>
    <style type="text/css">
        #nav_user {
            height: 30px;
            width: 100%;
            background-color: whitesmoke;
            font-size: 14px;
            list-style-type: none;
        }

        #nav_user ul {
            width: 80%;
            height: 25px;
            display: block;
            position: absolute;
            left: 10%;
        }

        #nav_user li {
            float: right;
            display: inline-block;
        }

        #nav_user a:hover {
            height: 28px;
            border-bottom: 2px #ffc900 solid;
            background-color: white;
        }

        #nav_user li a {
            width: 70px;
            height: 30px;
            display: inline-block;
            line-height: 30px;
            text-align: center;
            margin-left: 2px;
        }
    </style>
</head>
<body>
<div id="nav_user">
    <%
        String admin = String.valueOf(session.getAttribute("admin"));
        if (admin.length() > 0 && !"null".equals(admin)) {
    %>
    <ul>
        <li>
            <span style="font-size: 13px">
                您是管理员：&nbsp;<%=admin%>
            </span>
            <a href="javascript:exit();">退出登录</a>
        </li>
    </ul>
    <%
    } else {
    %>

    <ul>
        <li style="float: left;">
            <a href="index.jsp">首页</a>
        </li>
        <li style="float: left;">
            <a href="order_dish.jsp">点菜</a>
        </li>
        <li>
            <a href="#">联系我们</a>
        </li>
        <li>
            <a href="cart.jsp">购物车</a>
        </li>
        <li>
            <%
                String username = String.valueOf(session.getAttribute("username"));
                if (username.length() > 0 && !"null".equals(username)) {
            %>
            <span style="font-size: 13px">
                你好,&nbsp;<%=username%>
            </span>
            <a href="javascript:exit();">退出登录</a>
            <a href="list_order.jsp">查看订单</a>
            <a href="edit_user.jsp">个人信息</a>
            <%
            } else {
            %>
            <a href="login.jsp" style="width: 100px">未登录，请登录</a>
            <%
                }
            %>

        </li>
    </ul>

    <%
        }
    %>

</div>
</body>
</html>
